<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Request\Api;

use Hyperf\Validation\Request\FormRequest;

class CardVerifRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'card_no' => 'required',
            'lang' => 'sometimes'
        ];
    }

    public function messages(): array
    {
        $errMsg = 'The card number is required';

        if ($this->input('lang') == 'fr') {
            $errMsg = 'Le numéro de carte est requis';
        }elseif ($this->input('lang') == 'de') {
            $errMsg = 'Die Kartennummer ist erforderlich';
        }elseif ($this->input('lang') == 'nl') {
            $errMsg = 'Het kaartnummer is verplicht';
        }elseif ($this->input('lang') == 'it') {
            $errMsg = 'Il numero della carta è obbligatorio';
        }elseif ($this->input('lang') == 'es') {
            $errMsg = 'El número de tarjeta es obligatorio';
        }
        return [
            'card_no.required' => $errMsg,
        ];
    }
}
